package com.lkc.config;

import com.lkc.service.impl.ImageCleanupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

@Configuration
@EnableScheduling
public class ImageCleanupScheduleConfig {

    @Autowired
    private ImageCleanupService imageCleanupService;

    /**
     * 每10分钟执行一次图片清理任务
     */
    @Scheduled(fixedRate = 10 * 60 * 1000) // 10分钟 = 10*60*1000毫秒
    public void cleanupUnusedImages() {
        System.out.println("开始执行图片清理任务...");
        imageCleanupService.cleanupUnusedImages();
        System.out.println("图片清理任务执行完成");
    }
}
